package com.netflexitysolutions.amazonws.s3.internal.operations;

import com.amazonaws.s3.doc._2006_03_01.DeleteBucket;
import com.amazonaws.s3.doc._2006_03_01.Status;
import com.netflexitysolutions.amazonws.s3.S3;
import com.netflexitysolutions.amazonws.s3.S3ServerResponseStatus;

public class DeleteBucketOperation extends OperationExecutor<DeleteBucket, S3ServerResponseStatus> {

    private String bucket;

    public DeleteBucketOperation(S3 s3, String bucket){
        super(s3);
        this.bucket = bucket;
    }

    @Override
    protected S3ServerResponseStatus call(DeleteBucket request) {
        request.setBucket(bucket);
        injectCredentials(request, "DeleteBucket", getS3().getAccessKey(), getS3().getSecretKey());
        Status status = getS3().getService().deleteBucket(request).getDeleteBucketResponse();
        return new S3ServerResponseStatus(status.getCode(), status.getDescription());
    }
}